import React from 'react'
// ===================================================================== Temp
import Table from '#cpt/temp/Table'
// import TableControls from '#cpt/temp/TableControls'
// ===================================================================== Declare
const { $Lazy, $http, $fn } = window
// ===================================================================== Lazy
const Modal 			= $Lazy.state(()=>import('@antd/modal'))
// const SplitDom			= $Lazy.hook(()=>import('../../cpt/split-dom'))
// const ActionTable		= $Lazy.state(()=>import('./action-table'))
// const Confirm 			= $Lazy.file(()=>import('@antd/common/confirm-submit'))
// ===================================================================== component
const level = ['level1_value_avg', 'level2_value_avg', 'level3_value_avg', 'level4_value_avg', 'level5_value_avg', 'level6_value_avg', 'level7_value_avg', 'level8_value_avg', 'level9_value_avg']

class Index extends React.Component{
	state = {
		data: []
	}
	
	open = uuid => {
		this.uuid = uuid
		this.fetch()
		this.modalRef.open()
	}
	
	fetch = () => $http.pull(this,'qc-test/avgLog', {isIndex: 1, param: {test_id: this.uuid}}).then(data => {
		this.cols = [
			{ title: '开始时间', 		dataIndex: 'start_date', 			...$fn.table.time },
			{ title: '结束时间',			dataIndex: 'end_date', 				...$fn.table.time },
		]
		level.forEach(v => {
			data[0][v] && this.cols.push({ title: `水平${v.slice(5,6)}固定靶值`,			dataIndex: v, 				...$fn.table.spec_num })
		})
		this.cols.push({ title: '操作人',			dataIndex: 'operator_name', 		...$fn.table.name })
		this.table.table.updateCol(this.cols)
		this.setState({data})
		// cols
	})
	
	// 表单
	cols = []
	
	render(){
		return <>
			<Modal
				title	= '靶值记录'
				width 	= {600}
				height  = '70%'
				// okText	= '数据'
				// noCancel
				noOk
				noText 	= '关闭'
				onRef	= { ref => this.modalRef = ref }
				isFullScroll
			>
				<div className='fx h'>
					{ Table.call(this, {isIndex: 1}) }
				</div>
			</Modal>
		</>
	}
}

export default Index